83db16388daecd555dba877b6a0d15856e27e9ea,gpslogger/src/main/java/com/mendhak/gpslogger/senders/email/AutoEmailJob.java,AutoEmailJob,onRun,#,59

Before Change


        }

        AuthenticatingSMTPClient client = new AuthenticatingSMTPClient();
        try {
            String to = "recipient@email.com";
            // optionally set a timeout to have a faster feedback on errors
            client.setDefaultTimeout(10 * 1000);
            // you connect to the SMTP server
            client.connect(smtpServer, port);
            // you say ehlo  and you specify the host you are connecting from, could be anything
            client.ehlo("localhost");
            // if your host accepts STARTTLS, we're good everything will be encrypted, otherwise we're done here
            if (client.execTLS()) {

                client.auth(AuthenticatingSMTPClient.AUTH_METHOD.LOGIN, smtpUsername, smtpPassword);
                checkReply(client);

                client.setSender(fromAddress);
                checkReply(client);

                client.addRecipient(to);
                checkReply(client);

                Writer writer = client.sendMessageData();

                if (writer != null) {
                    SimpleSMTPHeader header = new SimpleSMTPHeader(fromAddress, to, subject);
                    writer.write(header.toString());
                    writer.write(body);
                    writer.close();
                    if(!client.completePendingCommand()) {// failure
                        throw new Exception("Failure to send the email "+ client.getReply() + client.getReplyString());
                    }
                } else {
                    throw new Exception("Failure to send the email "+ client.getReply() + client.getReplyString());
                }
            } else {
                throw new Exception("STARTTLS was not accepted "+ client.getReply() + client.getReplyString());
            }
        } catch (Exception e) {
            throw e;

After Change


            checkReply(client);
            // you say ehlo  and you specify the host you are connecting from, could be anything
            client.ehlo("localhost");
            checkReply(client);
            // if your host accepts STARTTLS, we're good everything will be encrypted, otherwise we're done here
            LOG.debug("Checking TLS...");

            boolean tlsAccepted = client.execTLS();

            client.auth(AuthenticatingSMTPClient.AUTH_METHOD.LOGIN, smtpUsername, smtpPassword);
            checkReply(client);

            client.setSender(fromAddress);
            checkReply(client);